#ifndef Collection_First
#define Collection_First
#ifdef __GNUG__
#pragma interface
#endif

#include "Container.h"

//---- abstract class Collection -----------------------------------------------

class Collection : public Container {
protected:
	Collection();
public:
	MetaDef(Collection);
	//---- management
	Object *Clone();
	void FreeAll();
	virtual void Empty(int);
	//      empty the contents of a collection and reinitialize it with a
	//      given capacity
		
	//---- manipulation
	virtual Object *Add(Object*);
	void AddVector(Object *op1, ...);
	void AddVector(va_list ap);
	virtual Object *Remove(Object*);
	virtual Object *RemovePtr(Object*);
	virtual void AddAll(Collection*);
	virtual void RemoveAll(Collection*);

	//---- enumerating
	//      the calling protocol for BoolFun and ObjFun is:
	//      Fun(this,CurrentOp,Arg)
	virtual Collection *Collect(ObjPtrFun, void *Arg= 0);
		// collect the elements returned by ObjPtrFun
	virtual Collection *Select(BoolFun, void *Arg= 0);
		// select all elements for the new collection where BoolFun returns true
	virtual Object* Detect(BoolFun, void *Arg= 0);
		// find first element where BoolFun returns true

	//---- printing
	OStream& PrintOn(OStream&);
	IStream& ReadFrom(IStream&);
protected:
	virtual int GrowBy(int capDelta);
};

//---- DeletedObject -----------------------------------------------------------
//     placeholder for deleted objects in a collection

class DeletedObject: public Object {
public:
	MetaDef(DeletedObject);
	DeletedObject();
};

#endif
